bitkeeper revision 1.501.1.2 (3f87baa7GCRi_yatMEUW36MM6ZAyEQ)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sat, 11 Oct 2003 08:09:11 +0000 (08:09 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Sat, 11 Oct 2003 08:09:11 +0000 (08:09 +0000)
xen_refresh_dev.c:
  new file

.rootkeys
extras/mini-os/Makefile
tools/misc/xen_refresh_dev.c [new file with mode: 0644]

index de66e17a7dc0541a2efcb266308cdef4e6d0cc08..b7f0367e0efc91885ea495ce6acf2f928ac2ace6 100644 (file)
--- a/.rootkeys
+++ b/.rootkeys
 3f13d81eQ9Vz-h-6RDGFkNR9CRP95g tools/misc/xen_nat_enable
 3f13d81e6Z6806ihYYUw8GVKNkYnuw tools/misc/xen_nat_enable.README
 3f1668d4F29Jsw0aC0bJEIkOBiagiQ tools/misc/xen_read_console.c
+3f87ba90EUVPQLVOlFG0sW89BCwouQ tools/misc/xen_refresh_dev.c
 3f72f1bdJPsV3JCnBqs9ddL9tr6D2g xen/COPYING
 3f841450eJvqAD1Dldc0_aOweGiglQ xen/GUEST_CHANGES
 3ddb79bcbOVHh38VJzc97-JEGD4dJQ xen/Makefile
index f437cf2f5860c71a132f5f7b02be19046e9c0b65..18ae585db790c80621511ad7d11ea1c59a4b2cab 100644 (file)
@@ -35,6 +35,7 @@ $(TARGET): hypervisor-ifs head.o $(OBJS)
 clean:
        find . -type f -name '*.o' | xargs rm -f
        rm -f *.o *~ core $(TARGET).elf $(TARGET).raw $(TARGET) $(TARGET).gz
+       find . -type l | xargs rm -f
 
 %.o: %.c $(HDRS) Makefile
        $(CC) $(CFLAGS) -c $< -o $@
diff --git a/tools/misc/xen_refresh_dev.c b/tools/misc/xen_refresh_dev.c
new file mode 100644 (file)
index 0000000..b9ea025
--- /dev/null
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * xen_refresh_dev.c
+ * 
+ * Refresh our view of a block device by rereading its partition table. This 
+ * is necessary to synchronise with VBD attaches and unattaches in Xen. 
+ * Currently there's no automatic plumbing of attach/unattach requests.
+ * 
+ * Copyright (c) 2003, K A Fraser
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/mount.h> /* BLKRRPART */
+
+int main(int argc, char **argv)
+{
+    int fd;
+
+    if ( argc != 2 )
+    {
+        fprintf(stderr, "xen_refresh_dev <blkdev>\ne.g., /dev/xvda\n");
+        return 1;
+    }
+
+    if ( (fd = open(argv[1], O_RDWR)) == -1 )
+    {
+        fprintf(stderr, "Error opening %s: %s (%d)\n",
+                argv[1], strerror(errno), errno);
+        return 1;
+    }
+
+    if ( ioctl(fd, BLKRRPART) == -1 )
+    {
+        fprintf(stderr, "Error executing BLKRRPART on %s: %s (%d)\n",
+                argv[1], strerror(errno), errno);
+        return 1;
+    }
+
+    close(fd);
+
+    return 0;
+}